package com.dengcj.epl.service.util;


import com.dengcj.epl.entity.ecology.workflow.NodeExecuterResult;

import java.util.Arrays;
import java.util.List;

public class NodeExecuterResultUtil {

    public static boolean execute(List<NodeExecuterResult> resultList){
        StringBuffer msgStringBuffer = new StringBuffer();
        boolean flag = true;
        int index = 1;
        for(NodeExecuterResult nodeExecuterResult : resultList){
            if(!nodeExecuterResult.getStatus()){
                flag = false;
                msgStringBuffer.append(index+". "+nodeExecuterResult.toString()+"<br>");
                index++;
            }
        }

        if(msgStringBuffer.length() > 0){
            throw new RuntimeException("<img src='https://imgo.114shouji.com/img2020/11/27/8/2020112748542863.jpg' width='50' height='50'><br/>"+msgStringBuffer.toString());
        }

        return flag;
    }

    public static boolean execute(NodeExecuterResult... msgArray){
        List<NodeExecuterResult> msgList = Arrays.asList(msgArray);
        return execute(msgList);
    }
}
